home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / cntrlc / trick.frm < prev    next >
Text File  |  1995-05-08  |  3KB  |  102 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   3060
  5.    ClientLeft      =   690
  6.    ClientTop       =   1485
  7.    ClientWidth     =   6510
  8.    Height          =   3465
  9.    Left            =   630
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3060
  12.    ScaleWidth      =   6510
  13.    Top             =   1140
  14.    Width           =   6630
  15.    Begin ComboBox Combo1 
  16.       Height          =   300
  17.       Left            =   120
  18.       TabIndex        =   3
  19.       Text            =   "FRAME"
  20.       Top             =   600
  21.       Width           =   1455
  22.    End
  23.    Begin Frame Frame1 
  24.       Caption         =   "0"
  25.       Height          =   1695
  26.       Index           =   0
  27.       Left            =   1800
  28.       TabIndex        =   0
  29.       Top             =   480
  30.       Width           =   3135
  31.       Begin CheckBox Check1 
  32.          Caption         =   "Check1"
  33.          Height          =   375
  34.          Index           =   0
  35.          Left            =   120
  36.          TabIndex        =   1
  37.          Top             =   600
  38.          Width           =   2655
  39.       End
  40.    End
  41.    Begin Label Label2 
  42.       Caption         =   "Select Frame"
  43.       Height          =   255
  44.       Left            =   120
  45.       TabIndex        =   4
  46.       Top             =   240
  47.       Width           =   1215
  48.    End
  49.    Begin Label Label1 
  50.       Caption         =   "CLICK ON FORM TO CREATE NEW FRAME"
  51.       Height          =   855
  52.       Left            =   120
  53.       TabIndex        =   2
  54.       Top             =   2160
  55.       Width           =   1335
  56.    End
  57. End
  58. Option Explicit
  59. Declare Function SetParent Lib "User" (ByVal hWndChild As Integer, ByVal hWndNewParent As Integer) As Integer
  60.  
  61. Sub Check1_Click (index As Integer)
  62.           
  63. End Sub
  64.  
  65. Sub Combo1_click ()
  66.     frame1(combo1.ListIndex).ZOrder 0
  67. End Sub
  68.  
  69. Sub Form_click ()
  70.  
  71.     Static inext As Integer         ' Declare Frame Counter
  72.     Dim A As Integer                ' Dummy for SetParent
  73.     Dim newFrameHnd As Integer      ' New Frame Handle
  74.     
  75.     inext = inext + 1               ' Increment Counter
  76.  
  77.     Load frame1(inext)              'Create new Frame
  78.     Load check1(inext)              'Create new checkbox
  79.  
  80.     newFrameHnd = frame1(inext).hWnd  'Get new Frame Handle
  81.  
  82.     '**** AND THE TRICK IS.... ****
  83.     A = SetParent(check1(inext).hWnd, newFrameHnd) 'Set Checkbox parent handle to New Frame handle
  84.     
  85.     frame1(inext).Caption = Str$(inext) 'Give new Frame a name
  86.     check1(inext).Caption = "This is on Form " + Str(inext)  'Checkbox name
  87.     
  88.     frame1(inext).Top = frame1(inext - 1).Top + 250 'Position
  89.     frame1(inext).Left = frame1(inext - 1).Left + 250
  90.  
  91.     check1(inext).Visible = -1 'Make Visible
  92.     frame1(inext).Visible = -1
  93.     frame1(inext).ZOrder 0     'Frame comes to front
  94.  
  95.     combo1.AddItem Str$(inext) ' Add to list
  96. End Sub
  97.  
  98. Sub Form_Load ()
  99.     combo1.AddItem " 0"
  100. End Sub
  101.  
  102.